package cn.yh.hospitalappointmentsystemdemo.service.impl;

import cn.yh.hospitalappointmentsystemdemo.domain.entity.RegistrationOrders;
import cn.yh.hospitalappointmentsystemdemo.domain.query.PageQuery;
import cn.yh.hospitalappointmentsystemdemo.domain.vo.PreAppointmentVo;
import cn.yh.hospitalappointmentsystemdemo.domain.vo.RegistrationOrdersVo;
import cn.yh.hospitalappointmentsystemdemo.mapper.OrdersMapper;
import cn.yh.hospitalappointmentsystemdemo.service.IOrdersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, RegistrationOrders> implements IOrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

    @Override
    public Page page(PageQuery pageQuery, Long patientId) {
        Page<RegistrationOrdersVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
        QueryWrapper<RegistrationOrdersVo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("t1.patient_id", patientId);
        queryWrapper.eq("t1.is_delete", 0);
        queryWrapper.orderByDesc("t1.status");
        return ordersMapper.page(page, queryWrapper);
    }
}
